using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using DomainLayer.Data.Entities;

namespace Infrastructure.Data.Mapping
{
	public class WaybillDistributionMap : EntityTypeConfiguration<WaybillDistribution>
	{
		public WaybillDistributionMap()
		{
			// Primary Key
			this.HasKey(t => new { t.WaybillType, t.EmployeeName });

			// Properties
			this.Property(t => t.WaybillType)
				.IsRequired()
				.HasMaxLength(20);
				
			this.Property(t => t.SignStatus)
				.HasMaxLength(20);
				
			this.Property(t => t.AcceptType)
				.HasMaxLength(20);
				
			this.Property(t => t.POSCode)
				.HasMaxLength(20);
				
			this.Property(t => t.EmployeeName)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.DeductNotes)
				.HasMaxLength(20);
				
			// Table & Column Mappings
			this.ToTable("WaybillDistribution");
			this.Property(t => t.IntoTime).HasColumnName("IntoTime");
			this.Property(t => t.WaybillNO).HasColumnName("WaybillNO");
			this.Property(t => t.WaybillType).HasColumnName("WaybillType");
			this.Property(t => t.NeedAmount).HasColumnName("NeedAmount");
			this.Property(t => t.NeedBackAmount).HasColumnName("NeedBackAmount");
			this.Property(t => t.FactAmount).HasColumnName("FactAmount");
			this.Property(t => t.FactBackAmount).HasColumnName("FactBackAmount");
			this.Property(t => t.SignStatus).HasColumnName("SignStatus");
			this.Property(t => t.AcceptType).HasColumnName("AcceptType");
			this.Property(t => t.POSCode).HasColumnName("POSCode");
			this.Property(t => t.SignTime).HasColumnName("SignTime");
			this.Property(t => t.EmployeeName).HasColumnName("EmployeeName");
			this.Property(t => t.DeductNotes).HasColumnName("DeductNotes");
		}
	}
}

